# -*- coding: utf-8 -*-
# @Time    : 2024/8/27 10:15
# @Author  : Jonny
# @File    : LuckGitlabProjectMain.py
# @Describe: LuckGitlabProjectMain入口
from flask import Blueprint, current_app
import time
from luck.core.LuckConstant import LuckConstant
from luck.gitlab.LuckGitlabProjectService import LuckGitlabProjectService

luck_gitlab_project_bp = Blueprint('luck_gitlab_project', __name__)


# 检查服务器资源服务状态
@luck_gitlab_project_bp.route('/gitlab/project')
def gitlab_project_index():
    print(f'小程序 于 {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))} 查看Gitlab Project部署服务')

    return {
        "code": LuckConstant.CODE_SUCCESS,
        "data": [
            "/gitlab/project"
            , "/gitlab/user/readUserData"
        ],
        "msg": "Gitlab Project部署服务"
    }


@luck_gitlab_project_bp.route('/gitlab/project/readProjectData')
def gitlab_project_read_project_data():
    config = current_app.config['CONFIG_DATA']
    config["gitlab_private_token"] = "MxPQfCtCouFohwQEPjs8"
    gitlab_project_service = LuckGitlabProjectService(config)
    gitlab_project_service.main()

    return {
        "code": LuckConstant.CODE_SUCCESS,
        "msg": "Gitlab Project数据同步成功"
    }
